/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package navigator;

import MVC.IController;
import com.teamdev.jxbrowser.Browser;

/**
 * @author Michael
 */
public class NavigatorController implements IController {

    private static NavigatorController __instance = null;
    private NavigatorModel _navigatorModel = null;

    /*
     * Constructor
     */
    private NavigatorController() {
        _navigatorModel = new NavigatorModel();
    }

    /*
     * Singleton
     */
    public static NavigatorController getInstance() {

        if (__instance == null) {
            __instance = new NavigatorController();
        }

        return __instance;
    }

    /*
     * Add a page to the page list of the navigator
     */
    public void addPage(Browser page) {
        Browser array[] = _navigatorModel.getPages();
        int i = array.length;
        array[i] = page;
    }
    
    /*
     * Add a page to the page list of the navigator
     */
    public void addPage(Browser page, int index) {
        Browser array[] = _navigatorModel.getPages();
        array[index] = page;
    }

    /*
     * Chage the current URL of a page
     */
    public void setPageURL(String oldURL, String newURL) {
        _navigatorModel.getPage(oldURL).navigate(newURL);
    }

    /**
     * @return the _navigateurModele
     */
    public NavigatorModel getNavigatorModel() {
        return _navigatorModel;
    }

    /**
     * @param navigateurModele the _navigateurModele to set
     */
    public void setNavigatorModel(NavigatorModel navigateurModele) {
        this._navigatorModel = navigateurModele;
    }
}
